package IHM;

import java.awt.event.ActionEvent;

import javax.swing.JEditorPane;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledEditorKit;

class StrikeThroughAction extends StyledEditorKit.StyledTextAction {

	public StrikeThroughAction() {
		super("");
	}

	public void actionPerformed(ActionEvent ae) {
		JEditorPane editor = getEditor(ae);
		if (editor != null) {
			StyledEditorKit kit = getStyledEditorKit(editor);
			boolean strikeThrough = (StyleConstants.isStrikeThrough(kit
					.getInputAttributes())) ? false : true;
			SimpleAttributeSet sas = new SimpleAttributeSet();
			StyleConstants.setStrikeThrough(sas, strikeThrough);
			setCharacterAttributes(editor, sas, false);
		}
	}
}
